﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace MethodWorx.Core.Extensions
{
    public static class MemberInfoExtensions
    {
        public static string GetDescription(this MemberInfo src)
        {
            if (src == null)
                throw new NullReferenceException();

            object [] da = src.GetCustomAttributes(typeof(DescriptionAttribute), true);
            if(da != null && da.Length >= 1)
            {
                return ((DescriptionAttribute)da[0]).Description;
            }
            else
                return src.Name;
        }
    }
}
